<?php

use Illuminate\Support\Facades\Route;

Route::get('/', 'PagesController@root')->name('root');

Auth::routes(["verify" => true]);
Route::get('products/favorites', 'ProductsController@favorites')->name('products.favorites');
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
Route::get("/","PagesController@root")->name("root")->middleware("verified");
Route::group(["middleware" => ['auth',"verified"]],function (){
    Route::get("user_addresses","UserAddressesController@index")->name("user_addresses.index");
    Route::get("user_addresses/create","UserAddressesController@create")->name("user_addresses.create");
    Route::post("user_addresses","UserAddressesController@store")->name("user_addresses.store");
    Route::get('user_addresses/{user_address}', 'UserAddressesController@edit')->name('user_addresses.edit');
    Route::put('user_addresses/{user_address}', 'UserAddressesController@update')->name('user_addresses.update');
    Route::delete('user_addresses/{user_address}', 'UserAddressesController@destroy')->name('user_addresses.destroy');
    Route::redirect('/', '/products')->name('root');
    Route::get('products', 'ProductsController@index')->name('products.index');
    Route::get('products', 'ProductsController@index')->name('products.index');
    Route::get('products/{product}', 'ProductsController@show')->name('products.show');
    Route::post('products/{product}/favorite', 'ProductsController@favor')->name('products.favor');
    Route::delete('products/{product}/favorite', 'ProductsController@disfavor')->name('products.disfavor');
    Route::post('cart', 'CartController@add')->name('cart.add');
    Route::get('cart', 'CartController@index')->name('cart.index');
    Route::delete('cart/{sku}', 'CartController@remove')->name('cart.remove');
    Route::post('orders', 'OrdersController@store')->name('orders.store');
    Route::get('orders', 'OrdersController@index')->name('orders.index');
    Route::get('orders/{order}', 'OrdersController@show')->name('orders.show');
});
